<!DOCTYPE html>
<html>
<head>
	<title>计算器</title>
	<meta charset="utf-8">
	<script type="text/javascript" src="jquery.min.js"></script>
	<style type="text/css">
		table,td {
			border: 0px solid black;
			border-collapse: collapse;
		}
		td div{
			/*width: 80px;*/
			height: 100px;
			display: flex;
			justify-content: center;
			align-items: center;
			width: 100%;
			padding: 0px;
		}
		button{
			border: 0px solid black;
			border-radius: 5px;
			color: black;
			background-color: #c0c0c0;
			width: 120px;
			height: 70px;
			font-size: 30px;
		}
		button:focus{
			outline: none;
		}
		button:hover{
			background-color: #ecf0f1;
		}
		input{
			width: 95%;
			height: 70px;
			border: 0px;
			/*padding: 0px;*/
			border-radius: 5px;
			font-size: 30px;
			padding-left: 5px;
			color: white;
		}
		#show:focus{
			outline: none;
		}
	</style>
</head>
<body>
	<div style="width: 100%;height: 700px;display: flex;justify-content: center;align-items: center;flex-direction: column;">
		<h3>垃圾分类问答</h3>
		<table>
			<tr>
				<td colspan="3">
					<div>
						<input style="background-color: #bdc3c7;color: black;font-size: 15px;" type="text" readonly="true" value="1.可回收垃圾;2.有害垃圾;3,厨余垃圾;4.其它垃圾">
					</div>
				</td>
			</tr>
			<tr>
				<td colspan="3">
					<div>
						<input id="input1" style="background-color: #bdc3c7;" type="text" name="" readonly="true" placeholder="点击开始按钮选择题目">
					</div>
				</td>
			</tr>
			<tr>
				<td>
					<div><button onclick="start()">开始</button></div>
				</td>
				<td>
					<div><button onclick="end()">停止</button></div>
				</td>
				<td>
					<div><button onclick="showAnswer()">结果</button></div>
				</td>
			</tr>
			<tr >
				<td colspan="3">
					<div>
						<input id="input2" style="background-color: #bdc3c7;" type="text" readonly="true" 
						placeholder="点击开始按钮选择题目">
					</div>
				</td>
			</tr>
		</table>
	</div>
	<script type="text/javascript">

		var rabish = [{"garbageId": 1, "garbageFlag": "纸类", "garbageInfo": "再生利用", "garbageName": "报纸", "garbageType": "可回收垃圾"},{"garbageId": 2, "garbageFlag": "纸类", "garbageInfo": "再生利用", "garbageName": "传单", "garbageType": "可回收垃圾"},{"garbageId": 3, "garbageFlag": "纸类", "garbageInfo": "再生利用", "garbageName": "杂志", "garbageType": "可回收垃圾"},{"garbageId": 4, "garbageFlag": "纸类", "garbageInfo": "再生利用", "garbageName": "旧书", "garbageType": "可回收垃圾"},{"garbageId": 5, "garbageFlag": "纸类", "garbageInfo": "再生利用", "garbageName": "纸板箱", "garbageType": "可回收垃圾"},{"garbageId": 6, "garbageFlag": "纸类", "garbageInfo": "再生利用", "garbageName": "未受污染的纸制品", "garbageType": "可回收垃圾"},{"garbageId": 7, "garbageFlag": "金属", "garbageInfo": "再生利用", "garbageName": "铁制品", "garbageType": "可回收垃圾"},{"garbageId": 8, "garbageFlag": "金属", "garbageInfo": "再生利用", "garbageName": "铜制品", "garbageType": "可回收垃圾"},{"garbageId": 9, "garbageFlag": "金属", "garbageInfo": "再生利用", "garbageName": "铝制品", "garbageType": "可回收垃圾"},{"garbageId": 10, "garbageFlag": "玻璃", "garbageInfo": "再生利用", "garbageName": "玻璃瓶罐", "garbageType": "可回收垃圾"},{"garbageId": 11, "garbageFlag": "玻璃", "garbageInfo": "再生利用", "garbageName": "平板玻璃", "garbageType": "可回收垃圾"},{"garbageId": 12, "garbageFlag": "玻璃", "garbageInfo": "再生利用", "garbageName": "其他玻璃制品", "garbageType": "可回收垃圾"},{"garbageId": 13, "garbageFlag": "除塑料袋外的塑料制品", "garbageInfo": "再生利用", "garbageName": "泡沫塑料", "garbageType": "可回收垃圾"},{"garbageId": 14, "garbageFlag": "除塑料袋外的塑料制品", "garbageInfo": "再生利用", "garbageName": "塑料瓶", "garbageType": "可回收垃圾"},{"garbageId": 15, "garbageFlag": "除塑料袋外的塑料制品", "garbageInfo": "再生利用", "garbageName": "硬塑料", "garbageType": "可回收垃圾"},{"garbageId": 16, "garbageFlag": "橡胶及橡胶制品", "garbageInfo": "再生利用", "garbageName": "橡胶及橡胶制品", "garbageType": "可回收垃圾"},{"garbageId": 17, "garbageFlag": "利乐包装", "garbageInfo": "再生利用", "garbageName": "牛奶盒", "garbageType": "可回收垃圾"},{"garbageId": 18, "garbageFlag": "饮料瓶", "garbageInfo": "再生利用", "garbageName": "可乐罐", "garbageType": "可回收垃圾"},{"garbageId": 19, "garbageFlag": "饮料瓶", "garbageInfo": "再生利用", "garbageName": "塑料饮料瓶", "garbageType": "可回收垃圾"},{"garbageId": 20, "garbageFlag": "饮料瓶", "garbageInfo": "再生利用", "garbageName": "啤酒瓶", "garbageType": "可回收垃圾"},{"garbageId": 21, "garbageFlag": "电池", "garbageInfo": "安全填埋、焚烧", "garbageName": "蓄电池", "garbageType": "有害垃圾"},{"garbageId": 22, "garbageFlag": "电池", "garbageInfo": "安全填埋、焚烧", "garbageName": "钮扣电池", "garbageType": "有害垃圾"},{"garbageId": 23, "garbageFlag": "废旧电子产品", "garbageInfo": "安全填埋、焚烧", "garbageName": "废旧电子产品", "garbageType": "有害垃圾"},{"garbageId": 24, "garbageFlag": "废旧灯管灯泡", "garbageInfo": "安全填埋、焚烧", "garbageName": "废旧灯管灯泡", "garbageType": "有害垃圾"},{"garbageId": 25, "garbageFlag": "过期药品", "garbageInfo": "安全填埋、焚烧", "garbageName": "过期药品", "garbageType": "有害垃圾"},{"garbageId": 26, "garbageFlag": "过期日用化妆品", "garbageInfo": "安全填埋、焚烧", "garbageName": "过期日用化妆品", "garbageType": "有害垃圾"},{"garbageId": 27, "garbageFlag": "染发剂", "garbageInfo": "安全填埋、焚烧", "garbageName": "染发剂", "garbageType": "有害垃圾"},{"garbageId": 28, "garbageFlag": "杀虫剂容器", "garbageInfo": "安全填埋、焚烧", "garbageName": "杀虫剂容器", "garbageType": "有害垃圾"},{"garbageId": 29, "garbageFlag": "除草剂容器", "garbageInfo": "安全填埋、焚烧", "garbageName": "除草剂容器", "garbageType": "有害垃圾"},{"garbageId": 30, "garbageFlag": "废弃水银温度计", "garbageInfo": "安全填埋、焚烧", "garbageName": "废弃水银温度计", "garbageType": "有害垃圾"},{"garbageId": 31, "garbageFlag": "废油漆桶", "garbageInfo": "安全填埋、焚烧", "garbageName": "废油漆桶", "garbageType": "有害垃圾"},{"garbageId": 32, "garbageFlag": "废打印机墨盒", "garbageInfo": "安全填埋、焚烧", "garbageName": "废打印机墨盒", "garbageType": "有害垃圾"},{"garbageId": 33, "garbageFlag": "硒鼓", "garbageInfo": "安全填埋、焚烧", "garbageName": "硒鼓", "garbageType": "有害垃圾"},{"garbageId": 34, "garbageFlag": "食物残余", "garbageInfo": "堆肥、制作饲料", "garbageName": "剩菜剩饭", "garbageType": "厨余垃圾"},{"garbageId": 35, "garbageFlag": "食物残余", "garbageInfo": "堆肥、制作饲料", "garbageName": "西餐糕点", "garbageType": "厨余垃圾"},{"garbageId": 36, "garbageFlag": "菜梗菜叶", "garbageInfo": "堆肥、制作饲料", "garbageName": "菜梗菜叶", "garbageType": "厨余垃圾"},{"garbageId": 37, "garbageFlag": "动物骨骼内脏", "garbageInfo": "堆肥、制作饲料", "garbageName": "动物骨骼内脏", "garbageType": "厨余垃圾"},{"garbageId": 38, "garbageFlag": "茶叶渣", "garbageInfo": "堆肥、制作饲料", "garbageName": "茶叶渣", "garbageType": "厨余垃圾"},{"garbageId": 39, "garbageFlag": "水果残余", "garbageInfo": "堆肥、制作饲料", "garbageName": "水果残余", "garbageType": "厨余垃圾"},{"garbageId": 40, "garbageFlag": "果壳瓜皮", "garbageInfo": "堆肥、制作饲料", "garbageName": "果壳瓜皮", "garbageType": "厨余垃圾"},{"garbageId": 41, "garbageFlag": "盆景等植物", "garbageInfo": "堆肥、制作饲料", "garbageName": "残枝落叶", "garbageType": "厨余垃圾"},{"garbageId": 42, "garbageFlag": "废弃食用油", "garbageInfo": "堆肥、制作饲料", "garbageName": "废弃食用油", "garbageType": "厨余垃圾"},{"garbageId": 43, "garbageFlag": "受污染与无法再生的纸张", "garbageInfo": "可燃部分焚烧发电，不可燃部分卫生填埋", "garbageName": "纸杯", "garbageType": "其它垃圾"},{"garbageId": 44, "garbageFlag": "受污染与无法再生的纸张", "garbageInfo": "可燃部分焚烧发电，不可燃部分卫生填埋", "garbageName": "照片", "garbageType": "其它垃圾"},{"garbageId": 45, "garbageFlag": "受污染与无法再生的纸张", "garbageInfo": "可燃部分焚烧发电，不可燃部分卫生填埋", "garbageName": "复写纸", "garbageType": "其它垃圾"},{"garbageId": 46, "garbageFlag": "受污染与无法再生的纸张", "garbageInfo": "可燃部分焚烧发电，不可燃部分卫生填埋", "garbageName": "压敏纸", "garbageType": "其它垃圾"},{"garbageId": 47, "garbageFlag": "受污染与无法再生的纸张", "garbageInfo": "可燃部分焚烧发电，不可燃部分卫生填埋", "garbageName": "收据用纸", "garbageType": "其它垃圾"},{"garbageId": 48, "garbageFlag": "受污染与无法再生的纸张", "garbageInfo": "可燃部分焚烧发电，不可燃部分卫生填埋", "garbageName": "明星片", "garbageType": "其它垃圾"},{"garbageId": 49, "garbageFlag": "受污染与无法再生的纸张", "garbageInfo": "可燃部分焚烧发电，不可燃部分卫生填埋", "garbageName": "相册", "garbageType": "其它垃圾"},{"garbageId": 50, "garbageFlag": "受污染与无法再生的纸张", "garbageInfo": "可燃部分焚烧发电，不可燃部分卫生填埋", "garbageName": "卫生纸", "garbageType": "其它垃圾"},{"garbageId": 51, "garbageFlag": "受污染与无法再生的纸张", "garbageInfo": "可燃部分焚烧发电，不可燃部分卫生填埋", "garbageName": "尿片", "garbageType": "其它垃圾"},{"garbageId": 52, "garbageFlag": "受污染或其他不可回收的玻璃", "garbageInfo": "可燃部分焚烧发电，不可燃部分卫生填埋", "garbageName": "受污染或其他不可回收的玻璃", "garbageType": "其它垃圾"},{"garbageId": 53, "garbageFlag": "塑料袋与其他受污染的塑料制品", "garbageInfo": "可燃部分焚烧发电，不可燃部分卫生填埋", "garbageName": "塑料袋与其他受污染的塑料制品", "garbageType": "其它垃圾"},{"garbageId": 54, "garbageFlag": "废旧衣物与其他纺织品", "garbageInfo": "可燃部分焚烧发电，不可燃部分卫生填埋", "garbageName": "废旧衣物与其他纺织品", "garbageType": "其它垃圾"},{"garbageId": 55, "garbageFlag": "破旧陶瓷品", "garbageInfo": "可燃部分焚烧发电，不可燃部分卫生填埋", "garbageName": "破旧陶瓷品", "garbageType": "其它垃圾"},{"garbageId": 56, "garbageFlag": "妇女卫生用品", "garbageInfo": "可燃部分焚烧发电，不可燃部分卫生填埋", "garbageName": "妇女卫生用品", "garbageType": "其它垃圾"},{"garbageId": 57, "garbageFlag": "一次性餐具", "garbageInfo": "可燃部分焚烧发电，不可燃部分卫生填埋", "garbageName": "一次性餐具", "garbageType": "其它垃圾"},{"garbageId": 58, "garbageFlag": "贝壳", "garbageInfo": "可燃部分焚烧发电，不可燃部分卫生填埋", "garbageName": "贝壳", "garbageType": "其它垃圾"},{"garbageId": 59, "garbageFlag": "烟头", "garbageInfo": "可燃部分焚烧发电，不可燃部分卫生填埋", "garbageName": "烟头", "garbageType": "其它垃圾"},{"garbageId": 60, "garbageFlag": "灰土", "garbageInfo": "可燃部分焚烧发电，不可燃部分卫生填埋", "garbageName": "灰土", "garbageType": "其它垃圾"}];
		rabish = eval(rabish);
		var garbageId = 0;
		//garbageName[garbageFlag]
		//注意:这里必须用$("#input1")[0],不能用$("#input1")[0].value
		var input1 = $("#input1")[0];
		//garbageType[garbageInfo]
		var input2 = $("#input2")[0];
		var clock = null;
		function start(){
			clock = setInterval(function(){
				//获得1-60内的随机整数
				garbageId = Math.ceil(Math.random()*60)+1;
				input1.value = rabish[garbageId].garbageName + "[" + rabish[garbageId].garbageFlag + "]";
				input2.value = "点击选择题目";
			},1000);
		}
		function end(){
			window.clearInterval(clock);
			input2.value = "显示答案";
		}
		function showAnswer(){
			input2.value = rabish[garbageId].garbageType + "[" + rabish[garbageId].garbageInfo + "]"
		}
	</script>
</body>
</html>